<!--
  用户账号添加页面
  User: Yzb
  Date: 2020-05-11
-->
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<!-- BEGIN FORM-->
<div class="portlet light">
    <div class="portlet-title">
        <div class="caption">
            <span class="caption-subject font-red-sunglo bold uppercase">停车场管理员添加</span>
            <span class="caption-helper">添加一条停车场管理员数据</span>
        </div>
    </div>
    <div class="portlet-body form">
        <!-- BEGIN FORM-->
        <form action="#" class="form-horizontal" id="save-module">
            <div class="form-body">

                <!-- 省 字段信息-->
                <div class="form-group ">
                    <label class="col-md-3 control-label">省份</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <select id="province" class="form-control" required name="province" onclick="chooseProvince()">
                                    <option>请选择省份</option>
                                    <option th:each="data,iterStat : ${cityList}" th:value="${data.id}"
                                            th:text="${data.name}"></option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 市 字段信息-->
                <div class="form-group ">
                    <label class="col-md-3 control-label">市区</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <select id="city" class="form-control" required name="city" onclick="chooseCity()">

                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 区县 字段信息-->
                <div class="form-group ">
                    <label class="col-md-3 control-label">区/县</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <select id="county" class="form-control" required name="county"></select>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 用户名 字段信息-->
                <div class="form-group">
                    <label class="col-md-3 control-label">登录帐号</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <input type="text" class="form-control" maxlength="32" required name="userName"
                                       placeholder="请输入登录帐号">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 登录密码 字段信息-->
                <div class="form-group">
                    <label class="col-md-3 control-label">登录密码</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <input type="password" class="form-control" maxlength="32" required name="password"
                                       placeholder="登录密码">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 昵称 字段信息-->
                <div class="form-group">
                    <label class="col-md-3 control-label">姓名</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <input type="text" class="form-control" maxlength="50" required name="name"
                                       placeholder="请输入姓名">
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 用户标签 字段信息  请选择管理员类型 -->
                <div class="form-group">
                    <label class="col-md-3 control-label">用户标签</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <select class="form-control" required name="managerType">
                                    <option value="">请选择管理员类型</option>
                                    <option value="park,admin,">停车场管理员</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 身份证 字段信息-->
                <div class="form-group">
                    <label class="col-md-3 control-label">身份证</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <input type="text" class="form-control" name="idCard" placeholder="身份证">
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 电话 字段信息-->
                <div class="form-group">
                    <label class="col-md-3 control-label">电话</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <input type="text" class="form-control"  name="phone" placeholder="电话">
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="form-actions">
                <div class="row">
                    <div class="col-md-12">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-7">
                                <button type="button" class="btn green" onclick="save();">保存</button>
                                <button type="button" class="btn default" onclick="layer.close(layer_parkManagerAddModule);">取消
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <!-- END FORM-->
    </div>
</div>

<script>

    $(function () {
        //初始化页面
        initPage();
    });

    //根据省ID选择市
    function chooseProvince() {
        $("#city").empty();
        $("#county").empty();
        var options = $("#province option:selected");
        if (options.text().trim() != "请选择省份" && "" != options.text().trim()) {
            tools.post("/city/findCityByParentId", {"parentId": options.val()}, function (data) {
                $("#city").append('<option value="">请选择市区</option>');
                for (let cs in data.data) {
                    $("#city").append("<option value=\"" + data.data[cs].id + "\">" + data.data[cs].name + "</option>");
                }
                ;
            });
        }
    }

    //根据市ID选择区/县
    function chooseCity() {
        $("#county").empty();
        var options = $("#city option:selected");
        if (options.text() != "请选择市区" && "" != options.text().trim()) {
            tools.post("/city/findCountyByParentId", {"parentId": options.val()}, function (data) {
                $("#county").append('<option value="">请选择区/县</option>');
                for (let cs in data.data) {
                    $("#county").append('<option value="' + data.data[cs].id + '">' + data.data[cs].name + '</option>')
                }
                ;
            });
        }
    }


    function save() {
        let param = tools.formParams("save-module");
        if (tools.valid("save-module")) {
            tools.post("/accountInfo/saveParkManager", param, function (data) {
                if (data.success) {
                    layer.msg(data.message, {icon: 1, time: 1000}, function () {
                        //刷新列表页面
                        toPage(null);
                        //关闭弹窗
                        layer.close(layer_parkManagerAddModule);
                    });
                } else {
                    tools.errorTip(data);
                }
            });
        }
    }

</script>
</html>